package core;

import java.util.Observer;
import java.util.Observable;
import org.apache.log4j.Logger;


/**
 * Class of the ChangesObserver object. Observes various objects, and takes actions
 * when changes are made.
 * 
 * @version 0.1
 * @author Sakis Vtdk
 */
public class ChangesObserver implements Observer
{
	/**
	 * @param o The Observable object (Database | Table | Column)
	 * @param arg The change that has happened
	 */
	@Override
	public void update(Observable o, Object arg)
	{
		log.debug("Change detected, updating ChangesLogger...");
		ChangesLogger changesLogger = ChangesLogger.getChangesLogger();
		Change newChange = (Change) arg;

		changesLogger.addChange(newChange);

		Database.getDatabase().setHasUnsavedChanges(Boolean.TRUE);
	}

	private static Logger log = Logger.getLogger(ChangesObserver.class);
}
